﻿using System.Linq.Expressions;
using Hvam.SharePoint.Search.Language;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hvam.SharePoint.Search.Tests.Public.Language
{
    [TestClass]
    public class KeywordQueryParserTests
    {
        [TestMethod]
        public void KeywordQueryParserParse()
        {
            // Arrange
            const string query = "title:title OR id=1";

            // Act
            var actual = KeywordQueryParser.Parse(query);

            // Assert
            var expected =
                Expression.Or(
                    KeywordQueryExpression.Contains(KeywordQueryExpression.Property("title"), Expression.Constant("title")),
                    Expression.Equal(KeywordQueryExpression.Property("id"), Expression.Constant("1"))
                    );

            AssertExpression.AreEqual(expected, actual);
        }
    }
}
